//
//  Appearance.swift
//  TuneMate
//
//  Created by 丸子 on 2023/11/23.
//

import UIKit


class Appearance {
    static let shared = Appearance()
    var accoutModel:AccountModel?
    
    var recordStyle:PaintImageDataModel?
    
    private var disposeBag = DisposeBag()
    private init() {}
    var bottomMiniPlayerHidden = true
    public static func addViewToWindow(_ view: UIView) {
        if #available(iOS 13.0, *) {
            guard let window = UIApplication.shared.windows.first(where: { $0.isKeyWindow }) else {
                return
            }
            window.addSubview(view)
        } else {
            guard let window = UIApplication.shared.delegate?.window else {
                return
            }
            window?.addSubview(view)
        }
    }
    
    
    public static func backSuperView() -> UIView? {
        if #available(iOS 13.0, *) {
            if let window = UIApplication.shared.windows.first(where: { $0.isKeyWindow }) {
                return window
            }
        } else {
            if let window = UIApplication.shared.delegate?.window {
                return window ?? nil
            }
        }
        // 如果没有找到 window，返回一个新的 UIView
        return nil
    }
    
    
    var isLoign:Bool {
        if Appearance.shared.accoutModel == nil {
            GlobalRx.loginSubject.onNext(())
            return false
        }else {
            return true
        }
    }
    
}
